<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>后台管理_编辑学校</title>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <script src="/js/jquery-2.0.3.min.js" type="text/javascript"></script>
    <script src="/js/jquery.validate.min.js" type="text/javascript"></script>
    <script src="/js/messages_bs_zh.js" type="text/javascript"></script>
    <script src="/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/kindeditor/themes/default/default.css" />
    <script charset="utf-8" src="/kindeditor/kindeditor-min.js"></script>
    <script charset="utf-8" src="/kindeditor/lang/zh_CN.js"></script>
    <link rel="stylesheet" href="/css/uploadify.css">
    <script src="/js/jquery.uploadify.min.js" type="text/javascript"></script>

</head>
<body>
<script language="JavaScript">
    $(document).ready(function(){
        $('#school-form').validate({
            rules: {
                name: {
                    required: true
                },
                description: {
                    required: true
                }
            },
            highlight: function(element) {
                $(element).closest('.form-group').removeClass('has-success').addClass('has-error');
            },
            success: function(element) {
                element
                        .addClass('valid')
                        .closest('.form-group').removeClass('has-error').addClass('has-success');
            },
            errorPlacement: function(error, element) {
                error.appendTo( element.parent("div").next("div") );
            },
            errorClass: "control-label"
        });
    });
    var editor;
    KindEditor.ready(function(K) {
        editor = K.create('textarea[name="prospectus"]', {
            resizeType : 1,
            allowPreviewEmoticons : false,
            uploadJson : "/uploadImage.do",
            items : [
                'source', '|', 'undo', 'redo', '|', 'preview','cut', 'copy', 'paste',
                'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                'insertunorderedlist', '|',  'image', 'link']
        });
    });

    var editor1;
    KindEditor.ready(function(K) {
        editor1 = K.create('textarea[name="description"]', {
            resizeType : 1,
            allowPreviewEmoticons : false,
            items : [
                'source', '|', 'undo', 'redo', '|', 'preview','cut', 'copy', 'paste',
                'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                'insertunorderedlist', '|',   'link']
        });
    });
    var editor2;
    KindEditor.ready(function(K) {
        editor1 = K.create('textarea[name="introduce"]', {
            resizeType : 1,
            allowPreviewEmoticons : false,
            items : [
                'source', '|', 'undo', 'redo', '|', 'preview','cut', 'copy', 'paste',
                'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                'insertunorderedlist', '|',   'link']
        });
    });

    $(function() {
        $('#file_upload').uploadify({
            'buttonText'  : '上传excel',
            'fileObjName' : 'file',
            'fileTypeDesc' : 'excel Files',
            'fileTypeExts' : '*.xlsx;*.xls',
            'swf'      : '/js/uploadify.swf',
            'uploader' : '/uploadExcel.do',
            'onUploadSuccess' : function(file, data, response) {
                var ret =  eval("("+data+")");
                editor.html(ret.table);
            },
            'onUploadError' : function(file, errorCode, errorMsg, errorString) {
                alert('The file ' + file.name + ' could not be uploaded: ' + errorString);
            }
        });
    });
    $(function() {
        $('#img_upload').uploadify({
            'buttonText'  : '上传logo图',
            'fileObjName' : 'imgFile',
            'fileTypeDesc' : 'image Files',
            'fileTypeExts' : '*.gif;*.jpg;*.png;*.bmp',
            'swf'      : '/js/uploadify.swf',
            'uploader' : '/uploadImage.do',
            'onUploadSuccess' : function(file, data, response) {
                var ret =  eval("("+data+")");
                if(ret["error"]==1)
                {
                    alert(ret["message"]);
                    return;
                }
                $("#logoimg").attr("src", ret.url);
                $("#logoimg").removeClass("hidden");
                $("#imgUrl").val(ret.url);
            },
            'onUploadError' : function(file, errorCode, errorMsg, errorString) {
                alert('The file ' + file.name + ' could not be uploaded: ' + errorString);
            }
        });
    });
    $(function() {
            $('#banner_upload').uploadify({
                'buttonText'  : '上传banner图',
                'fileObjName' : 'imgFile',
                'fileTypeDesc' : 'image Files',
                'fileTypeExts' : '*.gif;*.jpg;*.png;*.bmp',
                'swf'      : '/js/uploadify.swf',
                'uploader' : '/uploadImage.do',
                'onUploadSuccess' : function(file, data, response) {
                    var ret =  eval("("+data+")");
                    if(ret["error"]==1)
                    {
                        alert(ret["message"]);
                        return;
                    }
                    $("#bannerimg").attr("src", ret.url);
                    $("#div_banner").removeClass("hidden");
                    $("#banner").val(ret.url);
                },
                'onUploadError' : function(file, errorCode, errorMsg, errorString) {
                    alert('The file ' + file.name + ' could not be uploaded: ' + errorString);
                }
            });
        });
</script>
<div class="container" >
    <div class="row">
        <div class="col-md-4"></div>
        <div class="col-md-8">
            <ul class="nav nav-pills" >
                <li class="active"><a href="/man/school/list">学校管理</a> </li>
                <li><a href="/man/article/list">文章管理</a></li>
                <li><a href="/man/apply/list">报名管理</a></li>
            </ul>
        </div>
    </div>
    <p class="lead"></p>
    <form class="form-horizontal" id="school-form" action="/man/school/save" method="post">
        <input type="hidden" name="id" value="${school.id}">
        <div class="form-group">
            <label for="name" class="col-sm-4 control-label">学校名称</label>
            <div class="col-sm-5">
                <input type="text" class="form-control" id="name"  name="name" value="${school.name}"/>
            </div>
            <div class="col-sm-3"></div>
        </div>
        <div class="form-group">
            <label for="specialty" class="col-sm-4 control-label">招生专业</label>
            <div class="col-sm-5">
                <input type="text" class="form-control" id="specialty"  name="specialty" value="${school.specialty}">
            </div>
            <div class="col-sm-3"></div>
        </div>
        <div class="form-group">
            <label for="levels" class="col-sm-4 control-label">招生层次</label>
            <div class="col-sm-5">
                <input type="text" class="form-control" id="levels"  name="levels" value="${school.levels}">
            </div>
            <div class="col-sm-3"></div>
        </div>
        <div class="form-group">
            <label for="fee" class="col-sm-4 control-label">所有费用</label>
            <div class="col-sm-5">
                <input type="text" class="form-control" id="fee"  name="fee" value="${school.fee}">
            </div>
            <div class="col-sm-3"></div>
        </div>
        <div class="form-group">
            <label for="target" class="col-sm-4 control-label">招生对象</label>
            <div class="col-sm-5">
                <input type="text" class="form-control" id="target"  name="target" value="${school.target}">
            </div>
            <div class="col-sm-3"></div>
        </div>
        <div class="form-group">
            <label for="qq" class="col-sm-4 control-label">咨询QQ</label>
            <div class="col-sm-5">
                <input type="text" class="form-control" id="qq"  name="qq"  value="${school.qq}">
            </div>
            <div class="col-sm-3"></div>
        </div>
        <div class="form-group">
            <label for="phone" class="col-sm-4 control-label">报名电话</label>
            <div class="col-sm-5">
                <input type="text" class="form-control" id="phone"  name="phone" value="${school.phone}">
            </div>
            <div class="col-sm-3"></div>
        </div>
        <div class="form-group">
            <label for="mobile" class="col-sm-4 control-label">报名手机</label>
            <div class="col-sm-5">
                <input type="text" class="form-control" id="mobile"  name="mobile" value="${school.mobile}">
            </div>
            <div class="col-sm-3"></div>
        </div>
        <div class="form-group">
            <label for="address" class="col-sm-4 control-label">学校地址</label>
            <div class="col-sm-5">
                <input type="text" class="form-control" id="address"  name="address" value="${school.address}">
            </div>
            <div class="col-sm-3"></div>
        </div>
        <div class="form-group">
            <label for="introduce"  class="col-sm-4 control-label">简介</label>
            <div class="col-sm-5">
                <textarea name="introduce" class="form-control" id="introduce">${school.introduce}</textarea>
            </div>
            <div class="col-sm-3"></div>
        </div>
        <div class="form-group">
            <label for="description"  class="col-sm-4 control-label">学校介绍</label>
            <div class="col-sm-5">
                <textarea name="description" class="form-control" id="description">${school.description}</textarea>
            </div>
            <div class="col-sm-3"></div>
        </div>
        <div class="form-group">
            <label for="url1"  class="col-sm-4 control-label">学校介绍url</label>
            <div class="col-sm-5">
                <input type="text" class="form-control" id="url1"  name="url1" value="${school.url1}">
            </div>
            <div class="col-sm-3"></div>
        </div>
        <div class="form-group">
            <label for="prospectus"  class="col-sm-4 control-label">招生简章</label>
            <div class="col-sm-5">
                <textarea name="prospectus" class="form-control" id="prospectus">${school.prospectus}</textarea>
            </div>
            <div class="col-sm-3"></div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-5 col-sm-7">
                <input id="file_upload" name="file_upload" type="file" multiple="flase">
            </div>
        </div>
        <div class="form-group">
            <label for="url2"  class="col-sm-4 control-label">招生简章url</label>
            <div class="col-sm-5">
                <input type="text" class="form-control" id="url2"  name="url1" value="${school.url2}">
            </div>
            <div class="col-sm-3"></div>
        </div>
        <div class="form-group">
            <div class="col-sm-5" style="padding-left: 250px"><input id="img_upload" name="img_upload" type="file" multiple="flase"></div>
            <div class="col-sm-7">
                <img id="logoimg" width="180" height="135" src="" class="hidden"> <input id="imgUrl" name="imgUrl" type="hidden" value="${school.imgUrl}">
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-5" style="padding-left: 250px"><input id="banner_upload" name="banner_upload" type="file" multiple="flase"></div>
            <div class="col-sm-7">
                 <input id="banner" name="banner" type="hidden" value="${school.imgUrl}">
            </div>
        </div>
        <div class="form-group hidden" id="div_banner" style="padding-left: 250px">
            <img id="bannerimg" width="961" height="230" src="">
        </div>
        <div class="form-group">
            <div class="col-sm-offset-5 col-sm-7">
                <button type="submit" class="btn btn-primary">保存</button>
            </div>
        </div>
    </form>
</div>

</body>
</html>